package com.yuyou.fn.report.service;

import com.github.wens.framework.service.ISuperService;
import com.github.wens.mybatisplus.plugins.Page;
import com.yuyou.fn.educational.entity.PeriodSegment;
import com.yuyou.fn.educational.entity.Teacher;
import com.yuyou.fn.educational.vo.*;
import com.yuyou.fn.platform.permission.DataPermission;
import com.yuyou.fn.report.entity.MergeStudentRegDetail;
import com.yuyou.fn.report.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 *
 * StudentRegDetail 表数据服务层接口
 *
 */
public interface IMergeStudentRegDetailService extends ISuperService<MergeStudentRegDetail,Long> {

    Page<MergeStudentRegDetail> findStudentRegByQuery(StudentRegDetailQueryVo studentRegDetailQueryVo, int pageNo, int pageSize);



    List<MergeStudentRegDetail> findListStudentRegByQuery(List<Integer> regStatusList, PeriodQueryRegVo periodQueryRegVo, List<Long> gradeIds, List<Long> periodIds, List<Long> busTeamIds , String ...columns);

    List<MergeStudentRegDetail> findListByBusTeamIdsPeriodsGradeIds(List<Long> busTeamIds, List<Long> periodIds, List<Long> gradeIds, PeriodQueryRegVo periodQueryRegVo , String ...columns);

    List<MergeStudentRegDetail> findBySeniorIdsPeriodIds(List<Long> seniorIds, List<Long> periodIds, PeriodQueryRegVo periodQueryRegVo, String... columns);

    List<MergeStudentRegDetail> findByCounselorIdsPeriodIdsStates(List<Long> counselorIds, List<Long> periodIds, List<Integer> studentStates, PeriodQueryRegVo periodQueryRegVo, String... columns);


    List<MergeStudentRegDetail> findByAreaTeamIdPeriodIds(Long areaTeamId, List<Long> periodIds, PeriodQueryRegVo periodQueryRegVo, String... columns);

    List<MergeStudentRegDetail> findByTeacherIdsPeriodIds(List<Long> teacherIds, List<Long> periodIds, PeriodQueryRegVo periodQueryRegVo, String... columns);


    List<MergeStudentRegDetail> findByClassId(PeriodQueryRegVo periodQueryRegVo, List<Long> classIds, String... columns);




    List<RankByContinueClassVo> buildTeacherContinueRate(String key,List<RegRelativeVo> regRelativeVoList,List<Long> seqIdList,List<Long> stepIdList,Map<Long,Map<Integer,PeriodSegment>> periodSegmentMap);


    List<RankByContinueClassVo> findTeacherContinueRankRate(Teacher teacher,Long periodId);

    List<ClassRemunerationRankVo> findRegNumOrRemuneration(Teacher teacher, Long periodId);


    List<StudentAmountRankVo> buildStudentAmountRank(String key,List<RegRelativeVo> regRelativeVoList,List<Long> seqIdList,List<Long> stepIdList);

    List<StudentAmountRankVo> findStudentAmountRank(Teacher teacher,Long periodId);


    List<TeacherContinueRateVo> findTeacherContinueRate(String key,List<RegRelativeVo> regRelativeVoList,List<Long> seqIdList,List<Long> stepIdList);


    List<ClassBigRegNum> countBigRegNumByClassId(List<Long> busTeamIds, List<Long> periodIds, List<Long> gradeIds,List<Long> subjectIds, Integer lectureNum);

    List<AreaTeamRegDetailVo> countAreaTeamRegDetail(StudentRegDetailQueryVo studentRegDetailQueryVo);

    List<MergeStudentRegDetail> findListByAreaTeamIdPeriodIdsGradeId(Long areaTeamId, List<Long> periodIds, Long gradeId, String ...columns);

    List<RegDetailByClass> findClassRegDetail(List<Long> classIds);

    List<MergeStudentRegDetail> findByStudentIdsPeriodIds(List<Long> studentIds, List<Long> periodIds, PeriodQueryRegVo periodQueryRegVo, String ...columns);

    List<MergeStudentRegDetail> findByAreaTeamPeriodIds(Long areaTeamId, List<Long> periodIds, PeriodQueryRegVo periodQueryRegVo, String ...columns);

    List<RegRelativeVo> queryRegRelative(PeriodQueryRegVo periodQueryRegVo,RegRelativceQueryVo regRelativceQueryVo);

    List<RegRelativeVo> filterListByEffectiveLectureNum(List<RegRelativeVo> regRelativeVos,Map<Long,Map<Integer,PeriodSegment>> periodSegmentMap);

    List<RegRelativeVo> filterListByReportConfig(List<Long> periodIds,List<RegRelativeVo> regRelativeVos,Long resourceId);

    List<MergeStudentRegDetail> filterRegByEffectiveLectureNum(List<MergeStudentRegDetail> mergeStudentRegDetails,Map<Long,Map<Integer,PeriodSegment>> periodSegmentMap);

    List<MergeStudentRegDetail> filteRegByReportConfig(List<Long> periodIds,List<MergeStudentRegDetail> mergeStudentRegDetails,Long resourceId);

    List<MergeStudentRegDetail> findByStudentIdsQueryVo(List<Long> studentIds, StudentRegDetailQueryVo studentRegDetailQueryVo, String ...columns);

    List<SeniorStudentDetailVo>  findSeniorStudentDetail();


    List<MergeStudentRegDetail> findByStudentPhoneNosQueryVo(List<String> studentPhoneNos, StudentRegDetailQueryVo studentRegDetailQueryVo, String ...columns);


    Page<MergeStudentRegDetail> findRefundStudentRegPage(DataPermission dataPermission, StudentRegDetailQueryVo studentRegDetailQueryVo, int pageNo, int pageSize);

    Page<PeriodBusTeamGradeRegVo> findRegSituationPage(DataPermission dataPermission, StudentRegDetailQueryVo studentRegDetailQueryVo, int pageNo, int pageSize);

    SumRegVo findSumReg(DataPermission dataPermission, StudentRegDetailQueryVo studentRegDetailQueryVo);

    List<TeacherPeriodRefundDetailVo> findTeacherPeriodRefundDetail(long teacherId,long periodId);

    List<BusTeamPeriodGradeRegNumVo> findBusTeamPeriodGradeRegNum(SimpleQueryVo simpleQueryVo,int begin,int pageSize);

    Integer countBusTeamPeriodGradeRegNum(SimpleQueryVo simpleQueryVo);

    void deleteByStudentIdClassId(long studentId,long classId);

    MergeStudentRegDetail findByStudentIdClassId(long studentId,long classId);

    void deleteByStudentId(long studentId);

    List<MergeStudentRegDetail> findByStudentIdsClassIds(List<Long> studentIds,List<Long> classIds,String ...columns);

    /**
     *@Description: 判断报读的是否有效讲次
     *@Param:
     *@return:
     *@Author: lzh
     *@date:
     */
    Boolean checkClassBigEffectiveLectureNum(Integer lectureNum,Integer segmentNo, Long periodId, Map<Long,Map<Integer,PeriodSegment>> periodSegmentMap);


    /**
    *@Description: 咨询师新老生科数和金额
    *@Param:
    *@return:
    *@Author: lzh
    *@date:
    */
    List<NewOldStudentBranchAdvanceVo> findNewOldStudentBranchAmount(StudentRegDetailQueryVo studentRegDetailQueryVo);

    /**
    *@Description: 班主任续读生科数金额
    *@Param:
    *@return:
    *@Author: lzh
    *@date:
    */
    List<SeqStepStudentBranchAdvanceVo> findSeqStepStudentBranchAmount(RegRelativceQueryVo regRelativceQueryVo,PeriodQueryRegVo periodQueryRegVo);

    /**
    *@Description:网报新老生招生提成
    *@Param:
    *@return:
    *@Author: lzh
    *@date:
    */
    List<NoCounselorBranchVo> countBusTeamOlineNoCounselorBranch(StudentRegDetailQueryVo studentRegDetailQueryVo);

    /**
    *@Description: 咨询师新老续预收（基于生源类型）
    *@Param:
    *@return:
    *@Author: lzh
    *@date:
    */
    List<CounselorBranchAdvanceVo> findCounselorBranchAdvanceByStudentState(StudentRegDetailQueryVo studentRegDetailQueryVo);

    List<ClassPreIncomeDetailVo> findClassPreIncomeDetailVo(ClassPreIncomeDetailQueryVo classPreIncomeDetailQueryVo);

    /**
    *@Description: 通过班级id 统计在读数据
    *@Param:
    *@return:
    *@Author: lzh
    *@date:
    */
    Long countReadByClassIds(List<Long> classIds);

    List<MergeStudentRegDetail> findByStudentIdPeriodIdsChargingStatuses(long studentId, List<Long> periodIds, List<Integer> chargingStatuses) ;


    List<MergeStudentRegDetail> findByStudentIdsPeriodIdsChargingStatuses(List<Long> studentIds, List<Long> periodIds, List<Integer> chargingStatuses) ;

    /**
    *@Description: 统计 所选期数每个校区有多少人在读
    *@Param:
    *@return: 
    *@Author: lzh
    *@date: 
    */
    List<CampusPeriodsStudentNumVo> findCampusPeriodsRegNum(List<Long> periodIds);


    List<ClassAmountVo> findClassAmountByPeriodId(long periodId);
}